module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    transport: {

      options: {
        paths: ["."],
        alias: '<%= pkg.spm.alias %>',
        idleading: "http://cca.mbaobao.com/mkts/201604/29/<%=pkg.family%>/<%=pkg.name%>/<%=pkg.version%>/",
        debug: true,
        handlebars: {
          id: 'handlebars'
        }
      },
      hellosea: {
        // options: {
        //   idleading: 'http://cca.mbaobao.com/mkts/201512/10/xg/images/d/'

        // },
         options: {
                handlebars: {
                    id: 'handlebars'
                }
            },
        files: [{
   
          expand: true,
          cwd: 'src/',
          src: '**/*',
          filter: 'isFile',
          dest: '.build/'
        }]
      },
      hbs: {
          options: {
              debug: false
          },
          files: [{
              expand:true,
              cwd: 'src/',
              src: '**/*.handlebars',
              filter: 'isFile',
              dest: 'src/'
          }]
      }
    },
    concat: {
      hellosea: {
        options: {
          // 是否采用相对地址
          relative: true
        },
        files: {
          // 合并后的文件地址
          '.build/tc.js': ['.build/tc.js']
        }
      }
    },

    uglify: {
      options: {
        banner: '/* <%= pkg.name %> by <%= pkg.author.name %> <%= grunt.template.today("yyyy-mm-dd hh:MM") %> */\n'
      },
      hellosea: {
        files: {
          '.build/tc.js': ['.build/tc.js'] //对dist/application.js进行压缩，之后存入dist/application.js文件

        }
      }

    },
    cssmin: {
      options: {
        banner: '/* <%= pkg.name %> by <%= pkg.author.name %> <%= grunt.template.today("yyyy-mm-dd hh:MM") %> */\n'
      },
      minify: {
        expand: true,
        cwd: 'src/',
        src: ['*.css', '!*.min.css'],
        dest: '.build/',
        ext: '.css'
      }
    },
    // 'ftp-deploy': {
    //   release: {
    //     auth: {
    //       host: '10.9.7.11',
    //       port: "58421",
    //       authKey: 'ftp34'
    //     },
    //     src: '.build/',
    //     dest: '<%=pkg.family%>/<%= pkg.name %>/<%= pkg.version %>/',
    //   }
    // }
     "ftp-deploy": {
            test: {
                auth: {
                  host: '10.9.7.11',
                  port: "58421",
                  authKey: 'ftp34'
                },
                src: '.build/',
                dest: '/cca.mbaobao.com/mkts/201604/29/<%=pkg.family%>/<%=pkg.name%>/<%=pkg.version%>'
            },
            release: {
               auth: {
                  host: '10.9.7.11',
                  port: "58421",
                  authKey: 'ftp34'
                },
                src: '.build/',
                dest: '/cca.mbaobao.com/mkts/201604/30/<%=pkg.family%>/<%=pkg.name%>/<%=pkg.version%>'
            }
        }
  });

  grunt.loadNpmTasks('grunt-cmd-transport');
  grunt.loadNpmTasks('grunt-cmd-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-ftp-deploy');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.registerTask("hbs", ["transport:hbs"]);
  // grunt.registerTask('default', ['transport','concat','uglify',"cssmin:minify",'ftp-deploy:release']);
 grunt.registerTask('build', ['transport', 'concat', 'uglify', "cssmin:minify"]);
 grunt.registerTask('default', ['build','ftp-deploy:release']);
 grunt.registerTask('test', ['build','ftp-deploy:test']);



};